package com.xiaotao.service.impl;

import com.xiaotao.entity.Address;
import com.xiaotao.mapper.AddressMapper;
import com.xiaotao.service.AddressService;
import com.xiaotao.util.Result;
import com.xiaotao.util.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService {
    @Autowired
    private AddressMapper addressMapper;

    @Override
    public Result getAddr() throws Exception {
        Integer userId = UserContext.contextUserId();
        List<Address> addressList = addressMapper.getAddrByUserId(userId);
        return addressList!=null? Result.get(200,"查询成功",addressList):
                Result.get(500,"查询失败");
    }
}
